﻿namespace NKernel.Core
{
    using System;

    /// <summary>
    /// Convenience class to wrap two attributes during the return of a kernel method invocation.
    /// </summary>
    public sealed class KernelResult
    {
        #region Fields

        private readonly string message = String.Empty;
        private readonly bool success;

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="KernelResult"/> class.
        /// </summary>
        /// <param name="result">if set to <c>true</c> [result].</param>
        public KernelResult(bool result)
        {
            success = result;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="KernelResult"/> class.
        /// </summary>
        /// <param name="result">if set to <c>true</c> [result].</param>
        /// <param name="message">The message.</param>
        public KernelResult(bool result, string message)
        {
            success = result;
            this.message = message;
        }

        #endregion Constructors

        #region Properties

        /// <summary>
        /// Gets the message.
        /// </summary>
        /// <value>The message.</value>
        public string Message
        {
            get { return message; }
        }

        /// <summary>
        /// Gets a value indicating whether this <see cref="KernelResult"/> is success.
        /// </summary>
        /// <value><c>true</c> if success; otherwise, <c>false</c>.</value>
        public bool Success
        {
            get { return success; }
        }

        #endregion Properties
    }
}